<?php
/**
 * OWL Widget File
 *
 * Hello world widget
 * @package OWL
 * @subpackage Widgets 
 */

class Owl_Hello_Widgets extends Owl_Widgets {

    function Owl_Hello_Widgets() {
        $this->Owl_Widgets('hello', __('Hello world'), __('OWL widget say hello to you!'));
    }

    function widget($instance) {
        $message = !empty($instance['message']) ? $instance['message'] : __('Hello world, welcome to OWL!');
        echo Owl_Format::esc_html($message);
    }

    function update( $new_instance, $old_instance ) {
        $instance = $old_instance;
        $instance['title'] = Owl_Format::esc_html(strip_tags($new_instance['title']));
        $instance['message'] = Owl_Format::esc_html(strip_tags($new_instance['message']));
        return $instance;
    }

    function form( $instance ) {
        $instance = Owl_System_Helper::array_merge((array) $instance, array( 'title' => __('Hello world!'), 'message'=>__('Hello world, welcome to OWL!')));
    ?>
<p>
    <label for="<?php echo $this->get_field_id('title'); ?>" >
        <?php echo __('Title') . ":"; ?>
    </label>
    <input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance["title"]; ?>" class="widefat"/>
</p>
<p>
    <label for="<?php echo $this->get_field_id('message'); ?>">
        <?php echo __('Message') . ":"; ?>
    </label>
    <textarea id="<?php echo $this->get_field_id('message'); ?>" name="<?php echo $this->get_field_name('message'); ?>" rows="3" class="widefat"><?php echo $instance['message']; ?></textarea>
</p>
    <?php
    }
}

//Register it
register_widget(Owl_Hello_Widgets);
